#include <fstream>
#include <string>
#include "IniTest.h"

using namespace SystemTool;

static void LogFile(std::string strMsg)
{
    std::string strFilePath = "/Users/tangyingzhong/Desktop/12.log";
    std::fstream os(strFilePath,std::ios::out | std::ios::app);
    os << strMsg << "\n";
    os.close();
}

void IniTest()
{
    std::string strIniFilePath = "/Users/tangyingzhong/Desktop/12.ini";

    bool bValue = false;
    Ini::GetKey(strIniFilePath,"Sub","cold",bValue);
    Ini::SetKey(strIniFilePath,"Sub","cold",bValue);
    LogFile(std::to_string(bValue));

    std::string strValue = "Ricky";
    Ini::GetKey(strIniFilePath,"Main","name",strValue);
    Ini::SetKey(strIniFilePath,"Main","name",strValue);
    LogFile(strValue);

    int iAge = 30;
    Ini::GetKey(strIniFilePath, "Main", "age", iAge);
    Ini::SetKey(strIniFilePath, "Main", "age", iAge);
    LogFile(std::to_string(iAge));

    double dMoney = 189.2;
    Ini::GetKey(strIniFilePath,"Main","money",dMoney);
    Ini::SetKey(strIniFilePath,"Main","money",dMoney);
    LogFile(std::to_string(dMoney));

    long long girls = -34612384623846;
    Ini::GetKey(strIniFilePath,"Main","girls",girls);
    Ini::SetKey(strIniFilePath,"Main","girls",girls);
    LogFile(std::to_string(girls));

    unsigned long long boys = 34612384623846;
    Ini::GetKey(strIniFilePath,"Main","boys",boys);
    Ini::SetKey(strIniFilePath,"Main","boys",boys);
    LogFile(std::to_string(boys));
}
